<?php
  class Plugins_Gallery extends model {
  
  
  
  function getformadd($productid="")
  {
  
  
  
  
  $echo=1;
  $str='
  <div class="image1"> 
  
  <div ><a class="group" href="'.imgdefaultinfo.'/noimage.png" ><img width="160" height="160"  src="'.imgdefaultinfo.'/noimage.png"></a></div>
  <div><input type="button" name="upload[]" value="upload" ><input name="cloud[]" class="cloud1" type="button" value="cloud" ><input type="button" value="link" name="link[]" class="link1" ><input type="button" value="delete" name="delete[]" class="delete1" ></div> <div><input type="text" name="detail[]"></div>
  
  </div>
  
  
  <div class="image2"> 
  
  <div ><a class="group" href="'.imgdefaultinfo.'/noimage.png" ><img width="160" height="160"  src="'.imgdefaultinfo.'/noimage.png"></a></div>
  <div><input type="button" name="upload[]" value="upload" ><input name="cloud[]" class="cloud2" type="button" value="cloud" ><input type="button" value="link" name="link[]" class="link2" ><input type="button" value="delete" name="delete[]" class="delete2" ></div> <div><input type="text" name="detail[]"></div>
  
  </div>
  
  
  <div class="image3"> 
  
  <div ><a class="group" href="'.imgdefaultinfo.'/noimage.png" ><img width="160" height="160"  src="'.imgdefaultinfo.'/noimage.png"></a></div>
  <div><input type="button" name="upload[]" value="upload" ><input name="cloud[]" class="cloud3" type="button" value="cloud" ><input type="button" value="link" name="link[]" class="link3" ><input type="button" value="delete" name="delete[]" class="delete3" ></div> <div><input type="text" name="detail[]"></div>
  
  </div>
  
  
  
  <div class="image4"> 
  
  <div ><a class="group" href="'.imgdefaultinfo.'/noimage.png" ><img width="160" height="160"  src="'.imgdefaultinfo.'/noimage.png"></a></div>
  <div><input type="button" name="upload[]" value="upload" ><input name="cloud[]" class="cloud4" type="button" value="cloud" ><input type="button" value="link" name="link[]" class="link4" ><input type="button" value="delete" name="delete[]" class="delete4" ></div> <div><input type="text" name="detail[]"></div>
  
  </div>
  
  
  <div style="display:none">
   
  <div  class="royalSlider rsDefault" style="width: 100%; height: 300px;">
    <a class="rsImg"  href="'.imgdefaultinfo.'/noimage.png">
      <div class="rsTmb">
        <h5>The Epic & The Beasts</h5>
        <p>by Sebastian Linda</p>
      </div>
    </a>
    <a class="rsImg"  href="'.imgdefaultinfo.'/noimage.png">
      <div class="rsTmb">
        <h5>Dubstep Dispute</h5>
        <p>by Fluxel Media</p>
      </div>
    </a>
     <a class="rsImg"  href="'.imgdefaultinfo.'/noimage.png">
      <div class="rsTmb">
        <h5>Barcode Band</h5>
        <p>by Kang woon Jin</p>
      </div>
    </a>
   <a class="rsImg"  href="'.imgdefaultinfo.'/noimage.png">
      <div class="rsTmb">
        <h5>Samm Hodges Reel</h5>
        <p>by Animal</p>
      </div>
    </a>
</div>
  </div>
  
  ';
  
  $str='
                <div class="wrpPlg clBg5 clBd2 bdFull">
                    <div class="wrpOutAtcPlg">
                        <div class="wrpAtcPlg">
                            <span class="ico icoOri icoGalPlg"></span>
                            <div class="spnAtcPlg clTxtW">
                                <span class="fs03">Gallery</span><br>
                                <span class="rcmSizeAdd">recommended size: 640px x 360px or larger</span>
                            </div>
                        </div>
                    </div>
                    <div class="wrpTl">
                        <div title="Close" class="btnIco closeTl clBd3 mgBtm10 deleterowbutton">
                            <span class="ico icoCloseTl"></span>
                        </div>
                    </div>
                    <span class="desPlg desGal clTxt3 fs03">Select 4 images recommend size 640 x 360 px</span>
                    <div class="wrpOutGalPlg clearfix">
                        <div class="wrpGalPlg image1">
                            <div class="galArea clBd2 clBg5 bdFull">
                            <div class="plgAreaGallery"></div>
                                <div class="addGalTl">
                                    
                                    <div title="Browse" class="btnIco addImgTl clBd3 bdBtm uploadbutton">
                                        <span class="ico icoAddImgTl"></span>
                                        <div class="wrpUlFile">

                                        </div>
                                    </div>
                                    <div title="Cloud" class="btnIco addCldTl clBd3 bdBtm cloudbutton cloudset1">
                                        <span class="ico icoAddCldTl"></span>
                                    </div>
                                    <div title="Link" class="btnIco addLnkTl clBd3 bdBtm linkbutton linkset1">
                                        <span class="ico icoAddLnkTl"></span>
                                    </div>
                                    <div title="Remove" class="btnIco btnRmvTl deletebutton deleteset1">
                                        <span class="ico icoRmvTl"></span>
                                    </div>
                                </div>
                            </div>
                            <form class="frmGalPlg">
                                <textarea placeholder="Type text here to explain this image." class="inpAddCtnt clBg5 fs01 clTxt2"></textarea>
                            </form>    
                        </div>
                        <div class="wrpGalPlg image2">
                            <div class="galArea clBd2 clBg5 bdFull">
                            <div class="plgAreaGallery"></div>
                                <div class="addGalTl">
                                    
                                    <div title="Browse" class="btnIco addImgTl clBd3 bdBtm uploadbutton">
                                        <span class="ico icoAddImgTl"></span>
                                        <div class="wrpUlFile">

                                        </div>
                                    </div>
                                    <div title="Cloud" class="btnIco addCldTl clBd3 bdBtm cloudbutton cloudset2">
                                        <span class="ico icoAddCldTl"></span>
                                    </div>
                                    <div title="Link" class="btnIco addLnkTl clBd3 bdBtm linkbutton linkset2">
                                        <span class="ico icoAddLnkTl"></span>
                                    </div>
                                    <div title="Remove" class="btnIco btnRmvTl deletebutton deleteset2">
                                        <span class="ico icoRmvTl"></span>
                                    </div>
                                </div>
                            </div>
                            <form class="frmGalPlg">
                                <textarea placeholder="Type text here to explain this image." class="inpAddCtnt clBg5 fs01 clTxt2"></textarea>
                            </form>    
                        </div>
                        <div class="wrpGalPlg image3">
                            <div class="galArea clBd2 clBg5 bdFull">
                            <div class="plgAreaGallery"></div>
                                <div class="addGalTl">
                                
                                    <div title="Browse" class="btnIco addImgTl clBd3 bdBtm uploadbutton">
                                        <span class="ico icoAddImgTl"></span>
                                        <div class="wrpUlFile">

                                        </div>
                                    </div>
                                    <div title="Cloud" class="btnIco addCldTl clBd3 bdBtm cloudbutton cloudset3">
                                        <span class="ico icoAddCldTl"></span>
                                    </div>
                                    <div title="Link" class="btnIco addLnkTl clBd3 bdBtm linkbutton linkset3">
                                        <span class="ico icoAddLnkTl"></span>
                                    </div>
                                    <div title="Remove" class="btnIco btnRmvTl deletebutton deleteset3">
                                        <span class="ico icoRmvTl"></span>
                                    </div>
                                </div>
                            </div>
                            <form class="frmGalPlg">
                                <textarea placeholder="Type text here to explain this image." class="inpAddCtnt clBg5 fs01 clTxt2"></textarea>
                            </form>    
                        </div>
                        <div class="wrpGalPlg image4">
                            <div class="galArea clBd2 clBg5 bdFull">
                            <div class="plgAreaGallery"></div>
                                <div class="addGalTl">
                                    
                                    <div title="Browse" class="btnIco addImgTl clBd3 bdBtm uploadbutton">
                                        <span class="ico icoAddImgTl"></span>
                                        <div class="wrpUlFile">

                                        </div>
                                    </div>
                                    <div title="Cloud" class="btnIco addCldTl clBd3 bdBtm cloudbutton cloudset4">
                                        <span class="ico icoAddCldTl"></span>
                                    </div>
                                    <div title="Link" class="btnIco addLnkTl clBd3 bdBtm linkbutton linkset4">
                                        <span class="ico icoAddLnkTl"></span>
                                    </div>
                                    <div title="Remove" class="btnIco btnRmvTl deletebutton deleteset4">
                                        <span class="ico icoRmvTl"></span>
                                    </div>
                                </div>
                            </div>
                            <form class="frmGalPlg">
                                <textarea placeholder="Type text here to explain this image." class="inpAddCtnt clBg5 fs01 clTxt2"></textarea>
                            </form>    
                        </div>
                    </div>
                </div>
            ';
  
  
  
  $arraydata['form']=addslashes(str_replace(array("\r", "", "\r"), '', $str));
 // $arraydata['js'][]=pluginjsinfo.'/gallery.js';
  //$arraydata['js'][]=baseinfo.'/js/jquery.Jcrop.min.js';
 // $arraydata['js'][]=baseinfo.'/js/jquery.iuploader-1.0.js';
  
  
      
  
  
  
  return $arraydata;
  
  
  
  
  
  
  
  }
  
  function getformlanding($arraydata)
  {
$code="";
$rowcheck=0;
if(count($arraydata['gallery']))
{
$code = '<div class="ldIt wrpGalLd">';

foreach($arraydata['gallery'] as $value) {


if($value['imgmid']==0)
{
$rowcheck++;
}

$code.= '<div class="galLd w160" onclick="openmaingallery('.$value['simgmid'].')">';
$code.= '<div class="icoDefLd">';
$code.= '<span class="ico icoImgDefLd"></span>';
$code.= '<span>Image</span>';
$code.= '</div>';
$code.= '<div class="wrpImgDesGalLd">';
$code.= '<a href="javascript:void(0)"   class="galleryimage"><img id="img-'.$value['simgmid'].'"  title="'.$value['img']['newpath'].'" width="160" height="160" alt="'.$value['img']['width'].'|'.$value['img']['height'].'" src="'.$value['simg']['newpath'].'"><a/>';


$codeset="";
if($value['detail']=="")
{
$codeset='style="display:none"';
}
$code.= '<div class="desGalLd clTxtW" '.$codeset.'>';
$code.= '<div  class="ovlLd ovlGalLd w160">';
$code.= '<p class="cutTxt">'.$value['detail'].'</p>';
$code.= '</div>';
$code.= '</div>';
$code.= '</div>';
$code.= '</div>';
}
$code.= '<div class="emtGen"></div>';
$code.= '</div>';
}

if($rowcheck==4)
{
$code="";
}

$data['str']=$code;
$data['target']='secondtarget';


return $data;
  
  
  }
  
  function getplugin($plugreid)
  {
  
  $sql="select * from tb_plugins_gallery where plugreid=".$plugreid.' order by galleryid asc';
  $arrayplugin=$this->db->db_set_recordset($sql);
  $arraynewdata=array();
  if(count($arrayplugin))
  {
  $arraynewdata['productid']=$arrayplugin[0]['productid'];
  $arraynewdata['plugreid']=$plugreid;
   
  foreach($arrayplugin as $valueplugin)
  {
   $arraydata=array();
   $arraydata['galleryid']= $valueplugin['galleryid'];
   $arraydata['imgmid']= $valueplugin['imgmid'];
   $arraydata['img']= $this->getimagebyimgmid($arraydata['imgmid']);
   $arraydata['simgmid']= $valueplugin['simgmid'];
   $arraydata['simg']= $this->getimagebyimgmid($arraydata['simgmid']);
   $arraydata['detail']= $valueplugin['detail'];
   $arraynewdata['gallery'][]=$arraydata;
    
  }
  }else
  {
  
  $arraynewdata['gallery']=array();
  
  }
  

  
  return $arraynewdata;
  
  
  }
  
   function saveplugin($arraydata,$productid,$plugreid)
   {

   if(count($arraydata['imgmids']))
   {
   $row=0;
   
   foreach($arraydata['imgmids'] as  $valueimgmid)
   {
   $arraysetdata=array();
   $arraysetdata['productid']=$productid;
   $arraysetdata['plugreid']=$plugreid;
   $arraysetdata['detail']=$valueimgmid['detail'];
   
   
   
   if($valueimgmid['photomain'])
  {
  $valueimgmid['imgmid']= $this->savephotobase64($valueimgmid['photomain']);
  $valueimgmid['simgmids']=$valueimgmid['imgmid'];
  }
  else if($valueimgmid['photolink'])
            {
            $valueimgmid['imgmid']=$this->savephotolink($valueimgmid['photolink']);
            $valueimgmid['simgmids']=$this->savephotolink($valueimgmid['photolink'],300,300);
            unset($valueimgmid['photolink']); 
            
            }
   else if($valueimgmid['photopath'])
            {
            $valueimgmid['imgmid']=$this->savephotopath($valueimgmid['photopath']);
            $valueimgmid['simgmids']=$this->savephotopath($valueimgmid['photopath'],300,300);
            unset($valueimgmid['photopath']);  
            
            }
   
   
   if($valueimgmid['imgmid'])
   {
   $arraysetdata['imgmid']=$this->swicthpathimage($valueimgmid['imgmid'],$productid);
   
 if(NameDmconnex=='Canonlife') 
 {   
   
  $sql=' select other,tb_img.imgmid
FROM
tb_img
where other!="" and other!="false" and other like "%Model%" and tb_img.imgmid='.$arraysetdata['imgmid'];
          $dataimg=$this->db->db_set_1recordrow($sql);
          
          
          
          $otherdata= json_decode($dataimg['other']);
          $arraydata2['other']=object_to_array($otherdata);
  
 if($dataimg['imgmid'])
 {                            
 $model='';
 if($arraydata2['other']['IFD0']['Model'])
 {
 $model=$arraydata2['other']['IFD0']['Model'];
 $this->savetagrelatedata($model,$productid);
 
 }
 
 /*
  $len='';
 if($arraydata2['other']['EXIF'])
 {
 if($arraydata2['other']['EXIF']['UndefinedTag:0xA434'])
 {
 $len=$arraydata2['other']['EXIF']['UndefinedTag:0xA434'];
 $this->savetagrelatedata($len,$productid);
 }
 
 }
 
 
   $focus='';
 if($arraydata2['other']['EXIF'])
 {
 if($arraydata2['other']['EXIF']['FocalLength'])
 {
 $focus=$arraydata2['other']['EXIF']['FocalLength'];
$link=str_replace('/','-',$focus);
//$focus=eval($focus).'mm';
list($d1,$d2)=explode("/",$focus);
$focus=($d1/$d2).' mm';

$this->savetagrelatedata($focus,$productid);
 
 }
 
 }
 
 
 
 $shutter='';
 if($arraydata2['other']['EXIF'])
 {
 if($arraydata2['other']['EXIF']['ISOSpeedRatings'])
 {
 $shutter='ISO'.$arraydata2['other']['EXIF']['ISOSpeedRatings'];
 $this->savetagrelatedata($shutter,$productid);
 }
 }
 
 $aperture='';
  if($arraydata2['other']['COMPUTED'])
 {
 if($arraydata2['other']['COMPUTED']['ApertureFNumber'])
 {
 $aperture=$arraydata2['other']['COMPUTED']['ApertureFNumber'];
 $this->savetagrelatedata($aperture,$productid);
 }
 }
 
 
  $exposure='';
  if($arraydata2['other']['EXIF'])
 {
 if($arraydata2['other']['EXIF']['ExposureTime'])
 {
 $exposure=$arraydata2['other']['EXIF']['ExposureTime'];
  $this->savetagrelatedata($exposure,$productid);
 }
 }
 */
 }
  
 }
   
   
   
   }
   else
   {
   $arraysetdata['imgmid']="";
   }
   
   if($valueimgmid['simgmids']){$arraysetdata['simgmid']=$this->swicthpathimage($valueimgmid['simgmids'],$productid);}
   else {  $arraysetdata['simgmids']=""; }
   
   
   $row++;
   $this->db->db_set($arraysetdata,'tb_plugins_gallery');
   }
   }
   
   }
  
  
  }
?>
